package com.mxf.code.strategy_factory.service;


import com.mxf.code.strategy_factory.enums.StatisticalIndicatorsEnum;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 分析统计指标策略
 *
 * @author 28382
 */
@Service
public class AnalysisTableStrategyContext {
    private final Map<String, AnalysisTableService> analysisTableMap = new ConcurrentHashMap<>();

    public AnalysisTableStrategyContext(Map<String, AnalysisTableService> strategyMap) {
        this.analysisTableMap.putAll(strategyMap);
    }

    /**
     * @param statisticalIndicatorsEnum 指标枚举
     * @return com.mxf.code.strategy_factory.service.AnalysisTableService
     * @author mxf
     * @description 获取实际统计策略
     * @createTime 2023/5/26 14:08
     * @paramType [com.mxf.code.strategy_factory.enums.StatisticalIndicatorsEnum]
     */
    public AnalysisTableService getResource(StatisticalIndicatorsEnum statisticalIndicatorsEnum) {

        return analysisTableMap.get(statisticalIndicatorsEnum.getStrategyName());
    }
}
